package com.ruoyi.project.applet.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.applet.domain.Ratio;
import com.ruoyi.project.applet.service.IRatioService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 比例设置Controller
 * 
 * @author ruoyi
 * @date 2025-06-01
 */
@RestController
@RequestMapping("/applet/ratio")
public class RatioController extends BaseController
{
    @Autowired
    private IRatioService ratioService;

    /**
     * 查询比例设置列表
     */

    @GetMapping("/list")
    public TableDataInfo list(Ratio ratio)
    {
        startPage();
        List<Ratio> list = ratioService.selectRatioList(ratio);
        return getDataTable(list);
    }



    /**
     * 获取比例设置详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ratioService.selectRatioById(id));
    }

    /**
     * 新增比例设置
     */

    @Log(title = "比例设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Ratio ratio)
    {
        return toAjax(ratioService.insertRatio(ratio));
    }

    /**
     * 修改比例设置
     */

    @Log(title = "比例设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Ratio ratio)
    {
        return toAjax(ratioService.updateRatio(ratio));
    }

    /**
     * 删除比例设置
     */

    @Log(title = "比例设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ratioService.deleteRatioByIds(ids));
    }
}
